package com.zrrd.yunchmall.sale.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrrd.yunchmall.sale.entity.Coupon;
import com.zrrd.yunchmall.sale.entity.CouponHistory;
import com.zrrd.yunchmall.sale.service.ICouponHistoryService;
import com.zrrd.yunchmall.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LYY
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/couponHistory")
@Api(tags = "营销服务-")
public class CouponHistoryController {

    @Autowired
    private ICouponHistoryService couponHistoryService;

    @GetMapping("/list")
    @ApiOperation("查看优惠卷")
    public ResponseResult list(@RequestParam int pageSize,
                               @RequestParam int pageNum,
                               @RequestParam int couponId) {
        QueryWrapper queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("coupon_id",couponId);
        Page<CouponHistory>pageInfo=couponHistoryService.page(new Page<>(pageNum,pageSize),queryWrapper);
        return new ResponseResult<>(200,"查询成功!",pageInfo);
    }
}
